package com.java.tutorials.jdk7.paths;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Created by xuzhike on 2016/1/27.
 * http://www.java2s.com/Code/Java/JDK-7/Removingredundanciesbynormalizingapath.htm
 * Removing redundancies by normalizing a path
 */
public class Removingredundanciesbynormalizingapath {
    public static void main(String[] args) {
        Path path = Paths.get("/home/docs/../music/A.mp3");
        System.out.println("Absolute path: " + path.toAbsolutePath());
        System.out.println("URI: " + path.toUri());
        System.out.println("Normalized Path: " + path.normalize());
        System.out.println("Normalized URI: " + path.normalize().toUri());
        System.out.println();

        path = Paths.get("/home/./music/A.mp3");
        System.out.println("Absolute path: " + path.toAbsolutePath());
        System.out.println("URI: " + path.toUri());
        System.out.println("Normalized Path: " + path.normalize());
        System.out.println("Normalized URI: " + path.normalize().toUri());

    }
}
